package top.swimmer.tokenizer.core;

import top.swimmer.tokenizer.dictionary.DictionaryFactory;

import java.util.ArrayList;
import java.util.List;

public class Test {

    private static final String text = "我们都有一个家";
    private static final List<Integer> times = new ArrayList<Integer>() {{
        add(100);
        add(1000);
        add(10000);
        add(100000);
        add(1000000);
        add(10000000);
        add(100000000);
    }};

    public static void main(String[] args) throws InterruptedException {
//        ForwardMaximumMatching array = new ForwardMaximumMatching(DictionaryFactory.getArrayListDictionary());
//        ForwardMaximumMatching linked = new ForwardMaximumMatching(DictionaryFactory.getLinkedListDictionary());
        ForwardMaximumMatching set = new ForwardMaximumMatching(DictionaryFactory.getHashSetDictionary());
        ForwardMaximumMatching tow = new ForwardMaximumMatching(DictionaryFactory.getDoubleArrayTrieDictionary());

        System.out.println("times\t\tset\t\tdouble");
        for (Integer time : times) {
            long start = 0;
            long end = 0;
            System.out.print(time + "\t\t");
//            start = System.currentTimeMillis();
//            if (time <= 100) {
//                for (int i = 0; i < time; i++) {
//                    array.segmentation(text);
//                }
//            }
//            end = System.currentTimeMillis();
//            System.out.print((end - start) + "\t\t");
//
//            start = System.currentTimeMillis();
//            if (time <= 100) {
//                for (int i = 0; i < time; i++) {
//                    linked.segmentation(text);
//                }
//            }
//            end = System.currentTimeMillis();
//            System.out.print((end - start) + "\t\t");

            start = System.currentTimeMillis();
            for (int i = 0; i < time; i++) {
                set.segmentation(text);
            }
            end = System.currentTimeMillis();
            System.out.print((end - start) + "\t\t");

            start = System.currentTimeMillis();
            for (int i = 0; i < time; i++) {
                tow.segmentation(text);
            }
            end = System.currentTimeMillis();
            System.out.print((end - start));
            System.out.println();
        }
    }
}
